# coding=utf-8

# 数据库 创建表格操作

from rs_label.tools.db.db_conn import Connection


class CreateOp(object):

    def __init__(self, conn):
        """
        初始化样例
        :param conn: Connection类，就是数据库连接与数据库基本操作
        """
        self.__conn = conn

    def create_rs_label_category(self, rs_name):
        """
        为遥感图像任务创建分类类别表
        :param rs_name: 遥感任务名称
        :return:
        """
        create_table_sql = '''CREATE TABLE IF NOT EXISTS %s_label_name
                    (ID INT PRIMARY KEY     NOT NULL,
                    NAME            TEXT    NOT NULL);''' % rs_name
        print("create_table_sql:", create_table_sql)
        self.__conn.execute_in_db(create_table_sql)

    def create_rs_label(self, rs_name):
        """
        为遥感任务创建样本标记表
        :param rs_name:
        :return:
        """
        create_table_sql = '''CREATE TABLE IF NOT EXISTS %s_label
                    (ID INT PRIMARY KEY     NOT NULL,
                    X   INT                 NOT NULL,
                    Y   INT                 NOT NULL,
                    LAT REAL                NOT NULL,
                    LON REAL                NOT NULL,
                    LABEL INT               NOT NULL);''' % rs_name
        print(create_table_sql)
        self.__conn.execute_in_db(create_table_sql)
